package com.dutychain.handler.impl;

import com.dutychain.handler.Handler;
import com.dutychain.request.HttpRequest;

public class BodyCheckHandler extends Handler {
    @Override
    public void doFilter(HttpRequest request) {
        System.out.println("before filter BodyCheckHandler.");
        HttpRequest.Message message = request.getMessage();
        String body = message.getBody();
        if ( body == null || "".equals(body) ) {
            System.out.println("error: body of message can't be empty.");
            return;
        }
        if ( getNext() != null )
            getNext().doFilter(request);
        System.out.println("after filter BodyCheckHandler.");
    }
}
